package com.learn.oneday;

import org.apache.log4j.Logger;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * Futuretask
 *
 * @author ln
 * @Description: ${todo}
 * @date 2020/12/8
 */

public class ThreadCreate2 {

    private static final Logger LOGGER = Logger.getLogger(ThreadCreate2.class);

    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        FutureTask<Integer> futureTask = new FutureTask<>(new Callable<Integer>() {
//            @Override
//            public Integer call() throws Exception {
//                LOGGER.debug("running");
//                Thread.sleep(2000);//1000毫秒=1秒
//                return 100;
//            }
//        });
//
//        Thread thread = new Thread(futureTask,"mythread");
//        thread.start();
//
//        LOGGER.debug(futureTask.get());//等待线程返回的结果

        Thread t = new Thread(
                () -> {
                    while (true) {
                        LOGGER.debug("running");
                    }
                },"myThread");
        t.start();
    }
}
